import React from 'react';
import { inject, observer } from 'mobx-react';
import { Button, Spin, Modal, message } from 'antd';
import { WeaRightMenu, WeaNewScroll, WeaTop, WeaFormItem, WeaSelect, WeaSearchGroup, WeaInput, WeaBrowser, WeaDatePicker, WeaTools, WeaLocaleProvider, WeaUpload, WeaDialog, WeaTextarea } from 'ecCom';
import * as Util from "../../util/Util";
import { toJS } from "mobx";
import CubeLayout from "../../../govern/components/E9/cubeLayout";
const getLabel = WeaLocaleProvider.getLabel;
@inject('goalAddStore','goalCommonStore')
@observer
export default class GoalAdd extends React.Component {
    constructor(props) {
        super(props);
        this.state = {
            spinning: true,
            params: {
                goalName: '',//目标名称
                enddate: '',//结束时间
                remark: '',//描述
                principalid: [],//责任人
                parentid: [],//上级目标
                partnerid: [],//参与人
                sharerid:[],//分享人
                goalids: [],//相关目标
                taskids: [],//相关任务
                docids: [],//相关文档
                wfids: [],//相关流程
                crmids: [],//相关客户
                projectids: [],//相关项目
                relatedacc: "",//相关附件
                period: '3',//周期
                cate: '',//分类  默认备忘录
                status:'1',//状态进行中
                condtype:'',//2表示组织目标
                typeId:'',//目标类型 1公司目标 2分部目标 3部门目标
                orgId:'',//组织id
            },
            parentName: "",
            goalKey: false,
            viewHeight: this.getHeight(),
            cateData: [],  //分类
            periodData: [
                // {key: "0",selected: false,showname: ""},
                { key: "1", selected: false, showname: getLabel(19398, '月度') },
                { key: "2", selected: false, showname: getLabel(17495, '季度') },
                { key: "3", selected: true, showname: getLabel(17138, '年度') },
                { key: "4", selected: false, showname: getLabel(390757, '三年') },
                { key: "5", selected: false, showname: getLabel(390758, '五年') },
            ],
            statusData:[
                {
                    key: "1",
                    selected: true,
                    showname: getLabel(1960,'进行中'),
                },
                {
                    key: "2",
                    selected: false,
                    showname: getLabel(23774,'已完成')
                },
                {
                    key: "3",
                    selected: false,
                    showname: getLabel(1981,'已撤销')
                },
            ],
            menu: [
                {
                    key: '0',
                    icon: <i className='icon-coms-Save-as' />,
                    content: getLabel(86, '保存'),
                    onClick: key => this.doNewSave(),
                }],
            category: '',
            maxUploadSize: '',
            sortcond: "1",
        }
    }
    componentWillMount() {//一些初始化请求
        let { sortCond, period, principaler, nowyear , goalAddStore } = this.props;
        let isOrgGoal = this.props.isOrgGoal || this.props.goalCommonStore.isOrgGoal;
        period = period == "0" ? "3":period;
        WeaTools.callApi('/api/workrelate/goal/fileCategory', 'GET', {}).then((data) => {
            if (data.status == 1) {
                this.setState({ category: data.secId, maxUploadSize: data.maxsize, sortcond: sortCond });
            } else {
                this.setState({ sortcond: sortCond });
            }
      
            this.setPrincipalid(principaler);
            this.getParentName();
            this.computeEndDate(period,nowyear);
            this.setCondtype(); 
            this.setOrgGoal();
        });
        goalAddStore.initForm({doback:(flag)=>{
            if(!flag || isOrgGoal){ //未开启建模 或者是组织目标
                this.setState({spinning:false});
            }else{   //开启后
                if(!goalAddStore.isloading){
                    this.setState({spinning:true});
                }
            }
            this.getCates(); //加载分类

        }}); //建模初始化
    }

    componentDidMount(){
    }

    componentWillUnmount(){

    }

    componentWillReceiveProps(newprops) {
        if (Util.isEmpty(newprops.pgId)) {
            this.cleanValues();
        }
        // this.cleanValues();
        const { goalAddStore } = newprops;
        if (!goalAddStore.isloading) {
            this.setState({ spinning: true });
        }
        if ((this.props.period != newprops.period || (this.props.pgId != newprops.pgId && !Util.isEmpty(newprops.pgId))) || this.props.locationKey != newprops.locationKey) {
            this.setPrincipalid(newprops.principaler);
            this.computeEndDate(newprops.period);
            this.getParentName(newprops.pgId);
            this.setCondtype();
            this.setOrgGoal();
        }
    }

    setOrgGoal = () =>{
        let { goalCommonStore:{orgId, typeId} } = this.props;
        let { params } = this.state;
        params.orgId = orgId;
        params.typeId = typeId;
    }

    setCondtype = () =>{ 
        let { goalCommonStore:{condtype} } = this.props;
        let { params } = this.state;
        params.condtype = condtype;
    }

    //设置责任人默认值
    setPrincipalid(val) {
        let isOrgGoal = this.props.isOrgGoal || this.props.goalCommonStore.isOrgGoal;
        if (val && !isOrgGoal) {
            let { params } = this.state;
            params.principalid = [val];
            this.setState({ params: params });
        }
    }
    //获取所有分类
    getCates = () => {
        WeaTools.callApi('/api/workrelate/goal/getAllCates', 'GET').then((data) => {
            if (data.api_status == true) {
                let cateData = [];
                let cateList = data.cateList;
                let len = cateList.length;
                for (let i = 0; i < cateList.length; i++) {
                    let option = {};
                    option.key = cateList[i].id;
                    option.showname = cateList[i].catename;
                    cateData.push(option);
                }
                if(len > 0){
                    this.setState({cateData});
                }
            }
        });
    }

    getParentName(pgId) {
        let id = "";
        if (Util.isEmpty(pgId)) {
            pgId = this.props.pgId;
        }
        if (!Util.isEmpty(pgId)) {
            WeaTools.callApi('/api/workrelate/goal/getDetailView', 'GET', { companyGoalId: pgId }).then((data) => {
                if (data.status == true) {
                    let { params } = this.state;
                    params.parentid = [];
                    params.parentid.push({ id: pgId, name: data.companyGoalName });
                    this.setState({ params, parentName: data.companyGoalName, goalKey: true });
                }
            });
        }
    }

    initCallBack = () => {
        this.setState({ spinning: false });
    }

    getHeight() {
        // let { minusHeight } = this.props;
        // if (minusHeight == undefined) {
        //     minusHeight = 0;
        // }
        // return window.innerHeight - 60 - minusHeight;
        return window.innerHeight - 110;
    }

    doClose(optparams) {
        this.cleanValues();
        if (typeof this.props.doClose === "function") {
            this.props.doClose(optparams);
        }
    }
    cleanValues() {
        this.setState({
            spinning: false,
            params: {
                goalName: '',//目标名称
                enddate: '',//结束时间
                remark: '',//描述
                principalid: [],//责任人
                parentid: [],//上级目标
                partnerid: [],//参与人
                sharerid:[], //分享人
                taskids: [],//相关任务
                docids: [],//相关文档
                wfids: [],//相关流程
                crmids: [],//相关客户
                projectids: [],//相关项目
                relatedacc: "",//相关附件
                period: '3',//周期
                cate: '',//分类
                condtype:"", //2表示为组织目标
            },
            sortcond: "1",
            locationKey: ''
        });
        this.uploading = false;
        const {goalAddStore} = this.props;
        goalAddStore.cubeLayoutParame = {};
    }

    //新的保存调用方法
    doNewSave = () => {
        const { goalAddStore } = this.props;
        let isOrgGoal = this.props.isOrgGoal || this.props.goalCommonStore.isOrgGoal;
        let _this = this; 
        goalAddStore.saveGoal({
            doback: function (data, type, extendDatas) {
                _this.doSubmit(data, type, extendDatas);
            },
            isOrgGoal
        });
    }

    doSubmit = (data, _type, extendDatas) =>{
        let alldatas = this.state.params;
        if (_type == 1) {
            alldatas = { ...alldatas, ...data };
            alldatas.extendDatas = JSON.stringify(extendDatas);
            alldatas.isecme = 1;
            alldatas.goalName = data.name;
            let _alldatas = this.state.params;
            alldatas.parentid = _alldatas.parentid;
            alldatas.principalid = _alldatas.principalid;
            alldatas.cateid = _alldatas.cate;
            alldatas.status = _alldatas.status;
            alldatas.enddate = _alldatas.enddate;
            alldatas.period = _alldatas.period;
            const{goalAddStore:{isMandatoryArry}} = this.props;
            if(isMandatoryArry && isMandatoryArry.length>0){
                for(let i=0;i<isMandatoryArry.length;i++){
                    if(alldatas[isMandatoryArry[i]]==""){
                        Modal.warning({
                            title:  getLabel(558,'提示'),
                            content: getLabel(509065, '请输入必填项'),
                        });
                        return;
                    }
                }
            }
        }
        this.setState({params:alldatas})
        
        let canSave = true;
        let tname = alldatas.goalName;
        let principalid = alldatas.principalid
        if (Util.isBlank(tname)) {//标题为空
            canSave = false;
        }
        if(!principalid || principalid.length <= 0){
            canSave = false;
        }
        if (!canSave) {
            Modal.warning({
                title:  getLabel(558,'提示'),
                content: getLabel(509065, '请输入必填项'),
            });
            return;
        } else {
            this.setState({ spinning: true });
            if (this.uploading) {
                this.refs.addgoalupload.doUpload();
            } else {
                this.saveGoal(alldatas);
            }
        }
    }
    onInputChange = (values, type,datas) => {
        const {goalAddStore: { cubeLayoutParame } } = this.props;
        const { specialFields } = cubeLayoutParame;
        if(type == 'showorder' || type == 'target' || type == 'result'){
            if(!this.isNumber(values) && !Util.isEmpty(values)){
                message.warning(getLabel(508795,'请输入数字'));
                ModeForm.changeFieldValue(datas.fieldMark,{value:""})
                return;
            }
            if(values>=100000000){
                message.warning(getLabel(513087,'请输入小于1亿的数字，且只能保留两位小数'));
                ModeForm.changeFieldValue(datas.fieldMark,{value:""})
                return; 
            }
            if(values.indexOf(".")!=-1){
                values = parseFloat(values).toFixed(2);
            } 
        }
        if (type == 'period') {
            let datevalue = this.computeEndDate(values);
            for(let i in specialFields){  //建模开启调用
                if(specialFields[i]["fieldname"] == "enddate"){
                    ModeForm.changeFieldValue(i,{value:datevalue})
                }
            }
        } else {
            let { params } = this.state;
            params = { ...params, [type]: values };
            this.setState({ params });
        }
    }
    //判断是否为数字
    isNumber = (val) => {
        var regPos = /^\d+(\.\d+)?$/; //非负浮点数
        var regNeg = /^(-(([0-9]+\.[0-9]*[1-9][0-9]*)|([0-9]*[1-9][0-9]*\.[0-9]+)|([0-9]*[1-9][0-9]*)))$/; //负浮点数
        if(regPos.test(val) || regNeg.test(val)){
            return true;
        }else{
            return false;
        }
    }

    onChangeBrowser = (ids, names, datas, type) => {
        let { params } = this.state;
        params = { ...params, [type]: datas }
        this.setState({ params: params })
    }
    //判断是否有附件上传
    setUploading(listB) {
        if (listB.length > 0) {
            this.uploading = true;
        } else {
            this.uploading = false;
        }
    }
    //附件上传
    uploadChange(ids, list) {
        let { params } = this.state;
        params = { ...params, relatedacc: ids.toString() }
        this.saveGoal(params);
    }

    closeCurrentPage = () => {
        var userAgent = navigator.userAgent;
        if (userAgent.indexOf("Firefox") != -1 || userAgent.indexOf("Chrome") != -1) {
            window.location.href = "about:blank";
            window.close();
        } else {
            window.opener = null;
            window.open("", "_self");
            window.close();
        }
    }

    //保存目标方法
    saveGoal(alldatas) {
        for (let key in alldatas) {
            if (key == 'principalid' || key == 'parentid' || key == 'partnerid' || key == "sharerid" || key == 'taskids' ||
                key == 'docids' || key == 'wfids' || key == 'crmids' || key == 'projectids' || key == 'goalids') {
                let str = '', arr = [];
                if (Array.isArray(alldatas[key])) {
                    alldatas[key].forEach((element) => {
                        arr.push(element.id)
                    })
                    alldatas = { ...alldatas, [key]: arr.toString() }
                }
            }
        }
        if (this.props.parentData) {
            alldatas.parentid = this.props.parentData[0].id;
        }
        alldatas.sorttype = this.props.sortcond;
        WeaTools.callApi('/api/workrelate/goal/addGoal', 'POST', alldatas).then((data) => {
            if(data.code == 2){
                message.error(getLabel(524455, '不能选择此负责人，因为此负责人没有为该组织创建目标的权限'));
                // this.setState({ spinning: false });
                this.setState({ spinning: false });
                return;
            }
            this.cleanValues();
            if (data.status) {
                if (data.code == 1) {
                    // Modal.warn({
                    //     title: "提示",
                    //     content: '保存出错,您没有给已选上级目标新建下级目标的权限',
                    // });
                    message.error(getLabel(508882, '保存出错,您没有给已选上级目标新建下级目标的权限'));
                    // this.setState({ spinning: false });
                    this.doClose(optparams);//关闭弹出框
                    return;
                }
                if(data.code == -1){
                    Modal.error({
                        title: getLabel(15172, '系统提示'),
                        content: getLabel(508744, '保存出错,请重新尝试或联系管理员'),
                    });
                    return;
                }

                let optparams = {};
                let parentData = this.props.parentData;
                let addType = this.props.addType;
                let pgId = this.props.pgId;
                optparams.datas = data.datas;
                optparams.subdatas = data.subdatas;
                optparams.optkey = data.goalId;
                optparams.opttype = 'dialogAdd'
                let openSide = true;
                if (addType && addType == 'detailAdd' || !Util.isEmpty(pgId)) {  //如果是详情调用新建，则侧边不打开
                    openSide = false;
                }
                this.doClose(optparams);//关闭弹出框
                if (data.code == 0) {
                    if (typeof this.props.onAddSuccess === "function" && !Util.isEmpty(pgId)) {
                        this.props.onAddSuccess(optparams, parentData, openSide, pgId);
                    } else {
                        this.props.onAddSuccess(optparams, parentData, openSide);
                    }
                }
            } else {
                Modal.error({
                    title: getLabel(15172, '系统提示'),
                    content: getLabel(508744, '保存出错,请重新尝试或联系管理员'),
                });
            }


        });
    }

    //计算结束日期
    computeEndDate = (values,nowyear) => {
        let { params } = this.state;
        let date = new Date()
        let y = nowyear ? parseInt(nowyear) : date.getFullYear()
        let m = date.getMonth();
        if (values) {
            params.period = values;
        }
        if (params.period == "1") {
            params.enddate = Util.convertTimeToString(new Date(y, m + 1, 0))
        } else if (params.period == "2") {
            params.enddate = Util.convertTimeToString(new Date(y, m + 4, 0))
        } else if (params.period == "3") {
            params.enddate = Util.convertTimeToString(new Date(y + 1, 0, 0))
        } else if (params.period == "4") {
            params.enddate = Util.convertTimeToString(new Date(y + 4, 0, 0))
        } else if (params.period == "5") {
            params.enddate = Util.convertTimeToString(new Date(y + 6, 0, 0))
        }
        this.setState({ params })
        return params.enddate;
    }

    getEcmeFieldData = (path, param) => {
        let { parentData, goalAddStore: { isMandatoryArry,cubeLayoutParame },goalCommonStore:{condtype} } = this.props;
        let isOrgGoal = this.props.isOrgGoal || this.props.goalCommonStore.isOrgGoal;
        let { specialFields } = cubeLayoutParame;
        let { params,cateData,periodData,statusData } = this.state;
        if (_.has(specialFields, path)) {
            let _isMandatory = param.isMandatory;
            if(_isMandatory){
                isMandatoryArry.push(specialFields[path].fieldname);
            }
            if (specialFields[path].fieldname == 'parentid') {
                return <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@3rfiyl`} title={getLabel(19709, '上级目标')}
                    viewAttr={parentData ? 1 : (_isMandatory?3:2)}
                    onChange={(ids, names, datas) => { this.onChangeBrowser(ids, names, datas, "parentid") }}
                    replaceDatas={parentData ? parentData : params.parentid}
                    hasAdvanceSerach={true}
                    icon ="icon-coms-implement"
                    iconBgcolor="rgb(150, 53, 138)" dataParams={{condtype,parentid:0}}
                    type="wrlgoal" inputStyle={{ width: 245 }}  completeParams={{condtype,parentid:0}}
                    linkUrl="/spa/workrelate/static/index.html?#/main/workrelate/goal/goalDetail?id=" />
            }
            if(specialFields[path].fieldname == 'principalid'){
                let _title = getLabel(16936,'责任人')
                return <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@izenjs`} title={_title}
                viewAttr={_isMandatory?3:2}
                onChange={(ids, names, datas) => { this.onChangeBrowser(ids, names, datas, specialFields[path].fieldname) }}
                replaceDatas={toJS(params[specialFields[path].fieldname])} 
                type="1"  inputStyle={{ width: 245 }} viewAttr={3}/>
            }
            if(specialFields[path].fieldname == 'cateid'){
                return  <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@musjfl`} options={cateData} viewAttr={_isMandatory?3:2} value={params.cate} style={{ width: 245 }} onChange={v => this.onInputChange(v, "cate")} />
            }
            if(specialFields[path].fieldname == 'enddate'){
                return  <WeaDatePicker ecId={`${this && this.props && this.props.ecId || ''}_WeaDatePicker@hucllt`} viewAttr={_isMandatory?3:2} value={params.enddate} onChange={value => this.onInputChange(value, "enddate")} />
            }
            if(specialFields[path].fieldname == 'period'){
                return <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@k4l3t6`} options={periodData}viewAttr={_isMandatory?3:2} value={params.period} style={{ width: 245 }} onChange={v => this.onInputChange(v, "period")} />
            }

        }
        return null;
    }

    ecmeFieldEventCallBack = (datas) =>{
        let {goalAddStore: { cubeLayoutParame } } = this.props;
        let { specialFields } = cubeLayoutParame;
        let type =  datas.changetype;
        let newvalue = datas.fieldnewvalue;
        let fieldMark = datas.fieldMark;
        let fieldInfo = datas.fieldInfo;
        let fieldname = fieldInfo.fieldname;
        if(type == "onblur" && !Util.isEmpty(newvalue)){
            this.onInputChange(newvalue,fieldname,datas)
        }
    }

    render() {
        const { spinning, params, viewHeight, cateData, category, maxUploadSize, periodData, menu, sortcond, goalKey } = this.state;
        const { isDialog, height, sortCond, parentData, principaler, pgId, goalAddStore, goalCommonStore:{condtype} } = this.props;
        let isOrgGoal = this.props.isOrgGoal || this.props.goalCommonStore.isOrgGoal;
        if (sortCond != sortcond) {
            this.setState({ sortcond: sortCond });
        }
        let { cubeLayoutParame, getCardStorefun } = goalAddStore;
        let cubeFlag = Object.keys(toJS(cubeLayoutParame)).length > 0;
        return (
            <div className="wea-workrelate-goal-add">
                <Spin ecId={`${this && this.props && this.props.ecId || ''}_Spin@x5g2wi`} spinning={spinning} style={{ height: '100%' }}>
                    <WeaRightMenu ecId={`${this && this.props && this.props.ecId || ''}_WeaRightMenu@iu0ywm`} datas={menu} showUrlItem={false} style={{ height: '100%' }}>
                        {!isDialog && <WeaTop ecId={`${this && this.props && this.props.ecId || ''}_WeaTop@ejfjz0`}
                            title={getLabel(508587, '新建目标')}
                            icon={<i className='icon-coms-implement' />}
                            iconBgcolor='rgb(150, 53, 138)'
                            buttons={[(<Button ecId={`${this && this.props && this.props.ecId || ''}_Button@7m621k@savegoal`} type="primary" onClick={this.doSubmit}>{getLabel(86, '保存')}</Button>)]}
                            showDropIcon={true}
                            dropMenuDatas={menu}
                        />}
                        <WeaNewScroll ecId={`${this && this.props && this.props.ecId || ''}_WeaNewScroll@7tmco3`} height={height || viewHeight} style={{ padding: '0 10px' }}>
                            {(cubeFlag && !isOrgGoal) ? (CubeLayout({ cubeLayoutParame, "getEcmeFieldData": this.getEcmeFieldData, "callback": this.initCallBack,"ecmeFieldEventCallBack":this.ecmeFieldEventCallBack, getCardStorefun })) :
                                <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@o6tjdg`} title={getLabel(81711, '基本信息')} needTigger={true} showGroup={true}>
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@gzxvhp`}
                                        label={getLabel('33439', '名称')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}>
                                        <WeaInput ecId={`${this && this.props && this.props.ecId || ''}_WeaInput@336n6a`} onChange={(value) => this.onInputChange(value, "goalName")} placeholder={getLabel(509489, '请输入目标名称')} viewAttr={3} value={params.goalName} />
                                    </WeaFormItem>
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@9hu05a`}
                                        label={getLabel(500401, '类型')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}>
                                        <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@64hkou`} options={cateData} viewAttr={2} value={params.cate} style={{ width: 242 }} onChange={v => this.onInputChange(v, "cate")} />
                                    </WeaFormItem>
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@5xof6l`}
                                        label={getLabel(15386, '周期')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}>
                                        <WeaSelect ecId={`${this && this.props && this.props.ecId || ''}_WeaSelect@kmczsd`} options={periodData} viewAttr={2} value={params.period} style={{ width: 242 }} onChange={v => this.onInputChange(v, "period")} />
                                    </WeaFormItem>
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@85g33r`}
                                        label={getLabel(19709, '上级目标')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}>
                                        <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@nzzlaz`}
                                            onChange={(ids, names, datas) => { this.onChangeBrowser(ids, names, datas, "parentid") }}
                                            replaceDatas={parentData ? parentData : params.parentid}
                                            title={getLabel(19709, '上级目标')}
                                            type="wrlgoal"
                                            hasAdvanceSerach={true}
                                            icon ="icon-coms-implement"
                                            iconBgcolor="rgb(150, 53, 138)"
                                            viewAttr={parentData || !Util.isEmpty(pgId) ? 1 : 2}
                                            inputStyle={{ width: 242 }}
                                            linkUrl="/spa/workrelate/static/index.html?#/main/workrelate/goal/goalDetail?id="
                                            dataParams={{condtype,parentid:0}}
                                            completeParams={{condtype,parentid:0}}
                                        />
                                    </WeaFormItem>
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@hma65m`}
                                        label={getLabel(433, '描述')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}>
                                        <WeaTextarea ecId={`${this && this.props && this.props.ecId || ''}_WeaTextarea@y6b3xv`} onChange={(value) => this.onInputChange(value, "remark")} value={params.remark}
                                            placeholder={getLabel(508891, '请输入目标描述')} />
                                    </WeaFormItem>
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@50b6tr`}
                                        label={getLabel(2097, '负责人')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}>
                                        <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@kit0eu`}
                                            type={1}
                                            replaceDatas={params.principalid}
                                            inputStyle={{ width: 242 }}
                                            onChange={(ids, names, datas) => this.onChangeBrowser(ids, names, datas, "principalid")}
                                            title={getLabel(2097, '负责人')}
                                            viewAttr={3}
                                        />
                                    </WeaFormItem>
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@fe2ap1`}
                                        label={getLabel(15761, '参与人')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}>
                                        <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@61figm`}
                                            type={17}
                                            replaceDatas={params.partnerid}
                                            inputStyle={{ width: 242 }}
                                            onChange={(ids, names, datas) => this.onChangeBrowser(ids, names, datas, "partnerid")}
                                            isSingle={false}
                                            title={getLabel(15761, '参与人')}
                                        />
                                    </WeaFormItem>
                                    <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@r9yqd0`}
                                        label={getLabel(500372, '结束时间')}
                                        labelCol={{ span: 4 }}
                                        wrapperCol={{ span: 18 }}>
                                        <WeaDatePicker ecId={`${this && this.props && this.props.ecId || ''}_WeaDatePicker@sztt1r`} value={params.enddate} onChange={value => this.onInputChange(value, "enddate")} />
                                    </WeaFormItem>
                                </WeaSearchGroup >}
                            <WeaSearchGroup ecId={`${this && this.props && this.props.ecId || ''}_WeaSearchGroup@unibp1`} title={getLabel(383491, '相关信息')} needTigger={true} showGroup={true}>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@hetxkk`} label={getLabel(382586, '相关目标')} labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} className='plan-item-goal' >
                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@wz4hsi`} onChange={(ids, names, datas) => { this.onChangeBrowser(ids, names, datas, "goalids") }}
                                        title={getLabel(382586, '相关目标')} icon ="icon-portal-ModelingEngine"  type="wrlgoal" replaceDatas={params.goalids} dataParams={{condtype}} completeParams={{condtype}} viewAttr={2} isSingle={false} inputStyle={{ width: 242 }} />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@5ldk0k`} label={getLabel(33414, '相关任务')} labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} className='plan-item-task'>
                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@tcsn7u`} onChange={(ids, names, datas) => { this.onChangeBrowser(ids, names, datas, "taskids") }}
                                        title={getLabel(33414, '相关任务')} icon ="icon-coms-currency-Task" type="wrltsk" replaceDatas={params.taskids} viewAttr={2} isSingle={false} inputStyle={{ width: 242 }} />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@0g03o0`} label={getLabel(857, '相关文档')} labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} className='plan-item-doc'>
                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@wy579m`} title={getLabel('857', '相关文档')} icon ="icon-portal-doc" type={9} inputStyle={{ width: 242 }} replaceDatas={params.docids}
                                        onChange={(ids, names, datas) => this.onChangeBrowser(ids, names, datas, "docids")} isSingle={false} />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@lcarac`} label={getLabel(22105, '相关流程')} labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} className='plan-item-wf'>
                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@muagc6`} title={getLabel(22105, '相关流程')} icon ="icon-coms-Workflow-o" type={16} inputStyle={{ width: 242 }} onChange={(ids, names, datas) => this.onChangeBrowser(ids, names, datas, "wfids")}
                                        isSingle={false} replaceDatas={params.wfids} />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@1i3122`} label={getLabel(783, '相关客户')} icon ="icon-portal-crm" labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} className='plan-item-crm'>
                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@52gp5j`} title={getLabel(783, '相关客户')} type={7} inputStyle={{ width: 242 }} replaceDatas={params.crmids}
                                        onChange={(ids, names, datas) => this.onChangeBrowser(ids, names, datas, "crmids")} isSingle={false} />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@jjs0sm`} label={getLabel(782, '相关项目')} labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} className='plan-item-project'>
                                    <WeaBrowser ecId={`${this && this.props && this.props.ecId || ''}_WeaBrowser@8pno3k`} title={getLabel(782, '相关项目')} icon ="icon-coms-project" type={8} inputStyle={{ width: 242 }} replaceDatas={params.projectids}
                                        onChange={(ids, names, datas) => this.onChangeBrowser(ids, names, datas, "projectids")} isSingle={false} />
                                </WeaFormItem>
                                <WeaFormItem ecId={`${this && this.props && this.props.ecId || ''}_WeaFormItem@mzisq3`} label={getLabel(22194, '相关附件')} labelCol={{ span: 4 }} wrapperCol={{ span: 18 }} className='plan-item-file'>
                                    <WeaUpload ecId={`${this && this.props && this.props.ecId || ''}_WeaUpload@9aam86`} uploadUrl={'/api/doc/upload/uploadFile2Doc?category=' + category} category={category}
                                        viewAttr='1' showClearAll={false} autoUpload={false} maxUploadSize={maxUploadSize}
                                        getShowListDatas={(listT, listB) => this.setUploading(listB)}
                                        onChange={(ids, list) => this.uploadChange(ids, list)} ref={'addgoalupload'}
                                    />
                                </WeaFormItem>
                            </WeaSearchGroup>
                        </WeaNewScroll>
                    </WeaRightMenu>
                </Spin>
            </div>
        )
    }
};